var logDiv = null;
function log(str) {
if (!logDiv) {
- logDiv = document.createElement('div');
- document.body.appendChild(logDiv);
- logDiv.style["position"] = "absolute";
- logDiv.style["right"] = "0px";
+ logDiv = document.createElement('div');
+ document.body.appendChild(logDiv);
+ logDiv.style["position"] = "absolute";
+ logDiv.style["right"] = "0px";
}
logDiv.appendChild(document.createTextNode(str));
logDiv.appendChild(document.createElement('br'));
var callstack = [];
var isCallstackPopulated = false;
try {
- i.dont.exist+=0;
+ i.dont.exist+=0;
} catch(e) {
- if (e.stack) { // Firefox
- var lines = e.stack.split("\n");
- for (var i=0, len=lines.length; i<len; i++) {
- if (lines[i].match(/^\s*[A-Za-z0-9\-_\$]+\(/)) {
- callstack.push(lines[i]);
- }
- }
- // Remove call to getStackTrace()
- callstack.shift();
- isCallstackPopulated = true;
- } else if (window.opera && e.message) { // Opera
- var lines = e.message.split("\n");
- for (var i=0, len=lines.length; i<len; i++) {
- if (lines[i].match(/^\s*[A-Za-z0-9\-_\$]+\(/)) {
- var entry = lines[i];
- // Append next line also since it has the file info
- if (lines[i+1]) {
- entry += " at " + lines[i+1];
- i++;
- }
- callstack.push(entry);
- }
- }
- // Remove call to getStackTrace()
- callstack.shift();
- isCallstackPopulated = true;
- }
+ if (e.stack) { // Firefox
+ var lines = e.stack.split("\n");
+ for (var i=0, len=lines.length; i<len; i++) {
+ if (lines[i].match(/^\s*[A-Za-z0-9\-_\$]+\(/)) {
+ callstack.push(lines[i]);
+ }
+ }
+ // Remove call to getStackTrace()
+ callstack.shift();
+ isCallstackPopulated = true;
+ } else if (window.opera && e.message) { // Opera
+ var lines = e.message.split("\n");
+ for (var i=0, len=lines.length; i<len; i++) {
+ if (lines[i].match(/^\s*[A-Za-z0-9\-_\$]+\(/)) {
+ var entry = lines[i];
+ // Append next line also since it has the file info
+ if (lines[i+1]) {
+ entry += " at " + lines[i+1];
+ i++;
+ }
+ callstack.push(entry);
+ }
+ }
+ // Remove call to getStackTrace()
+ callstack.shift();
+ isCallstackPopulated = true;
+ }
}
if (!isCallstackPopulated) { //IE and Safari
- var currentFunction = arguments.callee.caller;
- while (currentFunction) {
- var fn = currentFunction.toString();
- var fname = fn.substring(fn.indexOf("function") + 8, fn.indexOf("(")) || "anonymous";
- callstack.push(fname);
- currentFunction = currentFunction.caller;
- }
+ var currentFunction = arguments.callee.caller;
+ while (currentFunction) {
+ var fn = currentFunction.toString();
+ var fname = fn.substring(fn.indexOf("function") + 8, fn.indexOf("(")) || "anonymous";
+ callstack.push(fname);
+ currentFunction = currentFunction.caller;
+ }
}
return callstack;
}
var callstack = getStackTrace();
var end = callstack.length;
if (len > 0)
- end = Math.min(len + 1, end);
+ end = Math.min(len + 1, end);
for (var i = 1; i < end; i++)
- log(callstack[i]);
+ log(callstack[i]);
}
var grab = new Object();
function getButtonMask (button) {
if (button == 1)
- return GDK_BUTTON1_MASK;
+ return GDK_BUTTON1_MASK;
if (button == 2)
- return GDK_BUTTON2_MASK;
+ return GDK_BUTTON2_MASK;
if (button == 3)
- return GDK_BUTTON3_MASK;
+ return GDK_BUTTON3_MASK;
if (button == 4)
- return GDK_BUTTON4_MASK;
+ return GDK_BUTTON4_MASK;
if (button == 5)
- return GDK_BUTTON5_MASK;
+ return GDK_BUTTON5_MASK;
return 0;
}
surface.visible = false;
surface.imageData = null;
- var image = new Image();
- image.width = width;
- image.height = height;
- image.surface = surface;
- surface.image = image;
- var toplevelElement;
-
- toplevelElement = image;
- document.body.appendChild(image);
+ var div = document.createElement('div');
+ div.surface = surface;
+ surface.div = div;
- surface.toplevelElement = toplevelElement;
- toplevelElement.style["position"] = "absolute";
- /* This positioning isn't strictly right for apps in another topwindow,
- * but that will be fixed up when showing. */
- toplevelElement.style["left"] = surface.x + "px";
- toplevelElement.style["top"] = surface.y + "px";
- toplevelElement.style["display"] = "inline";
+ document.body.appendChild(div);
- toplevelElement.style["visibility"] = "hidden";
+ div.style["position"] = "absolute";
+ div.style["left"] = surface.x + "px";
+ div.style["top"] = surface.y + "px";
+ div.style["width"] = surface.width + "px";
+ div.style["height"] = surface.height + "px";
+ div.style["display"] = "block";
+ div.style["visibility"] = "hidden";
surfaces[id] = surface;
stackingOrder.push(surface);
var surface = surfaces[id];
if (surface.visible)
- return;
+ return;
surface.visible = true;
var xOffset = surface.x;
var yOffset = surface.y;
- surface.toplevelElement.style["left"] = xOffset + "px";
- surface.toplevelElement.style["top"] = yOffset + "px";
- surface.toplevelElement.style["visibility"] = "visible";
+ surface.div.style["left"] = xOffset + "px";
+ surface.div.style["top"] = yOffset + "px";
+ surface.div.style["visibility"] = "visible";
restackWindows();
}
function cmdHideSurface(id)
{
if (grab.window == id)
- doUngrab();
+ doUngrab();
var surface = surfaces[id];
-
if (!surface.visible)
- return;
+ return;
surface.visible = false;
- var element = surface.toplevelElement;
-
- element.style["visibility"] = "hidden";
+ surface.div.style["visibility"] = "hidden";
}
function cmdSetTransientFor(id, parentId)
var surface = surfaces[id];
if (surface.transientParent == parentId)
- return;
+ return;
surface.transientParent = parentId;
if (parentId != 0 && surfaces[parentId]) {
- moveToHelper(surface, stackingOrder.indexOf(surfaces[parentId])+1);
+ moveToHelper(surface, stackingOrder.indexOf(surfaces[parentId])+1);
}
if (surface.visible) {
- restackWindows();
+ restackWindows();
}
}
function restackWindows() {
for (var i = 0; i < stackingOrder.length; i++) {
- var surface = stackingOrder[i];
- surface.toplevelElement.style.zIndex = i;
+ var surface = stackingOrder[i];
+ surface.div.style.zIndex = i;
}
}
var i = stackingOrder.indexOf(surface);
stackingOrder.splice(i, 1);
if (position != undefined)
- stackingOrder.splice(position, 0, surface);
+ stackingOrder.splice(position, 0, surface);
else
- stackingOrder.push(surface);
+ stackingOrder.push(surface);
for (var cid in surfaces) {
- var child = surfaces[cid];
- if (child.transientParent == surface.id)
- moveToHelper(child, stackingOrder.indexOf(surface) + 1);
+ var child = surfaces[cid];
+ if (child.transientParent == surface.id)
+ moveToHelper(child, stackingOrder.indexOf(surface) + 1);
}
}
function cmdDeleteSurface(id)
{
if (grab.window == id)
- doUngrab();
+ doUngrab();
var surface = surfaces[id];
var i = stackingOrder.indexOf(surface);
if (i >= 0)
- stackingOrder.splice(i, 1);
- var image = surface.image;
- image.parentNode.removeChild(image);
+ stackingOrder.splice(i, 1);
+ var div = surface.div;
+ div.parentNode.removeChild(div);
delete surfaces[id];
}
{
var surface = surfaces[id];
if (has_pos) {
- surface.positioned = true;
- surface.x = x;
- surface.y = y;
- }
- if (has_size) {
- surface.width = w;
- surface.height = h;
+ surface.positioned = true;
+ surface.x = x;
+ surface.y = y;
}
if (has_size) {
- surface.image.width = w;
- surface.image.height = h;
+ surface.width = w;
+ surface.height = h;
+
+ surface.div.style["width"] = surface.width + "px";
+ surface.div.style["height"] = surface.height + "px";
}
if (surface.visible) {
- if (has_pos) {
- var xOffset = surface.x;
- var yOffset = surface.y;
+ if (has_pos) {
+ var xOffset = surface.x;
+ var yOffset = surface.y;
- var element = surface.image;
-
- element.style["left"] = xOffset + "px";
- element.style["top"] = yOffset + "px";
- }
+ surface.div.style["left"] = xOffset + "px";
+ surface.div.style["top"] = yOffset + "px";
+ }
}
sendConfigureNotify(surface);
restackWindows();
}
-function copyRect(src, srcX, srcY, dest, destX, destY, width, height)
+function cmdWindowUpdate(id, texture_id)
{
- // Clip to src
- if (srcX + width > src.width)
- width = src.width - srcX;
- if (srcY + height > src.height)
- height = src.height - srcY;
-
- // Clip to dest
- if (destX + width > dest.width)
- width = dest.width - destX;
- if (destY + height > dest.height)
- height = dest.height - destY;
-
- var srcRect = src.width * 4 * srcY + srcX * 4;
- var destRect = dest.width * 4 * destY + destX * 4;
-
- for (var i = 0; i < height; i++) {
- var line = src.data.subarray(srcRect, srcRect + width *4);
- dest.data.set(line, destRect);
- srcRect += src.width * 4;
- destRect += dest.width * 4;
- }
-}
-
+ var surface = surfaces[id];
+ var texture_url = textures[texture_id];
-function markRun(dest, start, length, r, g, b)
-{
- for (var i = start; i < start + length * 4; i += 4) {
- dest[i+0] = dest[i+0] / 2 | 0 + r;
- dest[i+1] = dest[i+1] / 2 | 0 + g;
- dest[i+2] = dest[i+2] / 2 | 0 + b;
- }
+ surface.div.src = texture_url;
}
-function markRect(src, srcX, srcY, dest, destX, destY, width, height, r, g, b)
+function handleNode(parent, node_data, data_pos)
{
- // Clip to src
- if (srcX + width > src.width)
- width = src.width - srcX;
- if (srcY + height > src.height)
- height = src.height - srcY;
-
- // Clip to dest
- if (destX + width > dest.width)
- width = dest.width - destX;
- if (destY + height > dest.height)
- height = dest.height - destY;
-
- var destRect = dest.width * 4 * destY + destX * 4;
-
- for (var i = 0; i < height; i++) {
- if (i == 0 || i == height-1)
- markRun(dest.data, destRect, width, 0, 0, 0);
- else {
- markRun(dest.data, destRect, 1, 0 ,0, 0);
- markRun(dest.data, destRect+4, width-2, r, g, b);
- markRun(dest.data, destRect+4*width-4, 1, 0, 0, 0);
+ var type = node_data[data_pos++];
+ switch (type)
+ {
+ case 0: // TEXTURE
+ var x = node_data[data_pos++];
+ var y = node_data[data_pos++];
+ var width = node_data[data_pos++];
+ var height = node_data[data_pos++];
+ var texture_id = node_data[data_pos++];
+ var image = new Image();
+ image.width = width;
+ image.height = height;
+ image.style["position"] = "absolute";
+ image.style["left"] = x + "px";
+ image.style["top"] = y + "px";
+ var texture_url = textures[texture_id];
+ image.src = texture_url;
+ parent.appendChild(image);
+ break;
+
+ case 1: // CONTAINER
+ var len = node_data[data_pos++];
+ for (var i = 0; i < len; i++) {
+ data_pos = handleNode(parent, node_data, data_pos);
}
- destRect += dest.width * 4;
+ break;
+ default:
+ alert("Unexpected node type " + type);
}
+ return data_pos;
}
-function decodeBuffer(context, oldData, w, h, data, debug)
+function cmdWindowSetNodes(id, node_data)
{
- var i, j;
- var imageData = context.createImageData(w, h);
-
- if (oldData != null) {
- // Copy old frame into new buffer
- copyRect(oldData, 0, 0, imageData, 0, 0, oldData.width, oldData.height);
- }
-
- var src = 0;
- var dest = 0;
-
- while (src < data.length) {
- var b = data[src++];
- var g = data[src++];
- var r = data[src++];
- var alpha = data[src++];
- var len, start;
-
- if (alpha != 0) {
- // Regular data is red
- if (debug) {
- r = r / 2 | 0 + 128;
- g = g / 2 | 0;
- b = r / 2 | 0;
- }
-
- imageData.data[dest++] = r;
- imageData.data[dest++] = g;
- imageData.data[dest++] = b;
- imageData.data[dest++] = alpha;
- } else {
- var cmd = r & 0xf0;
- switch (cmd) {
- case 0x00: // Transparent pixel
- //log("Got transparent");
- imageData.data[dest++] = 0;
- imageData.data[dest++] = 0;
- imageData.data[dest++] = 0;
- imageData.data[dest++] = 0;
- break;
-
- case 0x10: // Delta 0 run
- len = (r & 0xf) << 16 | g << 8 | b;
- //log("Got delta0, len: " + len);
- dest += len * 4;
- break;
-
- case 0x20: // Block reference
- var blockid = (r & 0xf) << 16 | g << 8 | b;
-
- var block_stride = (oldData.width + 32 - 1) / 32 | 0;
- var srcY = (blockid / block_stride | 0) * 32;
- var srcX = (blockid % block_stride | 0) * 32;
-
- b = data[src++];
- g = data[src++];
- r = data[src++];
- alpha = data[src++];
-
- var destX = alpha << 8 | r;
- var destY = g << 8 | b;
-
- copyRect(oldData, srcX, srcY, imageData, destX, destY, 32, 32);
- if (debug) // blocks are green
- markRect(oldData, srcX, srcY, imageData, destX, destY, 32, 32, 0x00, 128, 0x00);
-
- //log("Got block, id: " + blockid + "(" + srcX +"," + srcY + ") at " + destX + "," + destY);
-
- break;
-
- case 0x30: // Color run
- len = (r & 0xf) << 16 | g << 8 | b;
- //log("Got color run, len: " + len);
-
- b = data[src++];
- g = data[src++];
- r = data[src++];
- alpha = data[src++];
-
- start = dest;
-
- for (i = 0; i < len; i++) {
- imageData.data[dest++] = r;
- imageData.data[dest++] = g;
- imageData.data[dest++] = b;
- imageData.data[dest++] = alpha;
- }
-
- if (debug) // Color runs are blue
- markRun(imageData.data, start, len, 0x00, 0x00, 128);
-
- break;
-
- case 0x40: // Delta run
- len = (r & 0xf) << 16 | g << 8 | b;
- //log("Got delta run, len: " + len);
+ var surface = surfaces[id];
+ surface.node_data = node_data;
- b = data[src++];
- g = data[src++];
- r = data[src++];
- alpha = data[src++];
+ var div = surface.div;
- start = dest;
+ /* We use a secondary div so that we can remove all previous children in one go */
+ var oldDiv2 = null;
- for (i = 0; i < len; i++) {
- imageData.data[dest] = (imageData.data[dest] + r) & 0xff;
- dest++;
- imageData.data[dest] = (imageData.data[dest] + g) & 0xff;
- dest++;
- imageData.data[dest] = (imageData.data[dest] + b) & 0xff;
- dest++;
- imageData.data[dest] = (imageData.data[dest] + alpha) & 0xff;
- dest++;
- }
- if (debug) // Delta runs are violet
- markRun(imageData.data, start, len, 0xff, 0x00, 0xff);
- break;
-
- default:
- alert("Unknown buffer commend " + cmd);
- }
- }
- }
+ if (div.hasChildNodes())
+ oldDiv2 = div.lastChild;
- return imageData;
-}
+ var div2 = document.createElement('div');
-function cmdWindowUpdate(id, texture_id)
-{
- var surface = surfaces[id];
- var texture_url = textures[texture];
+ var end = handleNode(div2, node_data, 0);
+ if (end != node_data.length)
+ alert ("Did not consume entire array (len " + node_data.length + " end " + end + ")");
- surface.image.src = texture_url;
+ div.appendChild(div2);
+ if (oldDiv2)
+ div.removeChild(oldDiv2);
}
function cmdUploadTexture(id, data)
{
sendInput ("u", []);
if (grab.window)
- doUngrab();
+ doUngrab();
}
var active = false;
}
while (cmd.pos < cmd.length) {
- var id, x, y, w, h, q;
- var command = cmd.get_char();
- lastSerial = cmd.get_32();
- switch (command) {
- case 'D':
- alert ("disconnected");
- inputSocket = null;
- break;
-
- case 's': // create new surface
- id = cmd.get_16();
- x = cmd.get_16s();
- y = cmd.get_16s();
- w = cmd.get_16();
- h = cmd.get_16();
- var isTemp = cmd.get_bool();
- cmdCreateSurface(id, x, y, w, h, isTemp);
- break;
-
- case 'S': // Show a surface
- id = cmd.get_16();
- cmdShowSurface(id);
- break;
-
- case 'H': // Hide a surface
- id = cmd.get_16();
- cmdHideSurface(id);
- break;
-
- case 'p': // Set transient parent
- id = cmd.get_16();
- var parentId = cmd.get_16();
- cmdSetTransientFor(id, parentId);
- break;
-
- case 'd': // Delete surface
- id = cmd.get_16();
- cmdDeleteSurface(id);
- break;
-
- case 'm': // Move a surface
- id = cmd.get_16();
- var ops = cmd.get_flags();
- var has_pos = ops & 1;
- if (has_pos) {
- x = cmd.get_16s();
- y = cmd.get_16s();
- }
- var has_size = ops & 2;
- if (has_size) {
- w = cmd.get_16();
- h = cmd.get_16();
- }
- cmdMoveResizeSurface(id, has_pos, x, y, has_size, w, h);
- break;
-
- case 'r': // Raise a surface
- id = cmd.get_16();
- cmdRaiseSurface(id);
- break;
-
- case 'R': // Lower a surface
- id = cmd.get_16();
- cmdLowerSurface(id);
- break;
-
- case 'b': // Update window
- id = cmd.get_16();
- texture = cmd.get_32();
+ var id, x, y, w, h, q;
+ var command = cmd.get_char();
+ lastSerial = cmd.get_32();
+ switch (command) {
+ case 'D':
+ alert ("disconnected");
+ inputSocket = null;
+ break;
+
+ case 's': // create new surface
+ id = cmd.get_16();
+ x = cmd.get_16s();
+ y = cmd.get_16s();
+ w = cmd.get_16();
+ h = cmd.get_16();
+ var isTemp = cmd.get_bool();
+ cmdCreateSurface(id, x, y, w, h, isTemp);
+ break;
+
+ case 'S': // Show a surface
+ id = cmd.get_16();
+ cmdShowSurface(id);
+ break;
+
+ case 'H': // Hide a surface
+ id = cmd.get_16();
+ cmdHideSurface(id);
+ break;
+
+ case 'p': // Set transient parent
+ id = cmd.get_16();
+ var parentId = cmd.get_16();
+ cmdSetTransientFor(id, parentId);
+ break;
+
+ case 'd': // Delete surface
+ id = cmd.get_16();
+ cmdDeleteSurface(id);
+ break;
+
+ case 'm': // Move a surface
+ id = cmd.get_16();
+ var ops = cmd.get_flags();
+ var has_pos = ops & 1;
+ if (has_pos) {
+ x = cmd.get_16s();
+ y = cmd.get_16s();
+ }
+ var has_size = ops & 2;
+ if (has_size) {
+ w = cmd.get_16();
+ h = cmd.get_16();
+ }
+ cmdMoveResizeSurface(id, has_pos, x, y, has_size, w, h);
+ break;
+
+ case 'r': // Raise a surface
+ id = cmd.get_16();
+ cmdRaiseSurface(id);
+ break;
+
+ case 'R': // Lower a surface
+ id = cmd.get_16();
+ cmdLowerSurface(id);
+ break;
+
+ case 'b': // Update window
+ id = cmd.get_16();
+ var texture = cmd.get_32();
cmdWindowUpdate(id, texture);
break;
- case 't': // Upload texture
- id = cmd.get_32();
+ case 't': // Upload texture
+ id = cmd.get_32();
var data = cmd.get_data();
cmdUploadTexture(id, data);
break;
- case 'T': // Upload texture
- id = cmd.get_32();
+ case 'T': // Release texture
+ id = cmd.get_32();
cmdReleaseTexture(id);
break;
- case 'g': // Grab
- id = cmd.get_16();
- var ownerEvents = cmd.get_bool ();
+ case 'n': // Set nodes
+ id = cmd.get_16();
+ var len = cmd.get_32();
+ var node_data = new Uint32Array(len);
+ for (var i = 0; i < len; i++)
+ node_data[i] = cmd.get_32();
+
+ cmdWindowSetNodes(id, node_data);
+ break;
+
+ case 'g': // Grab
+ id = cmd.get_16();
+ var ownerEvents = cmd.get_bool ();
- cmdGrabPointer(id, ownerEvents);
- break;
+ cmdGrabPointer(id, ownerEvents);
+ break;
- case 'u': // Ungrab
- cmdUngrabPointer();
- break;
+ case 'u': // Ungrab
+ cmdUngrabPointer();
+ break;
case 'k': // show keyboard
showKeyboard = cmd.get_16() != 0;
showKeyboardChanged = true;
break;
- default:
- alert("Unknown op " + command);
- }
+ default:
+ alert("Unknown op " + command);
+ }
}
return true;
}
function handleOutstanding()
{
while (outstandingCommands.length > 0) {
- var cmd = outstandingCommands.shift();
- if (!handleCommands(cmd)) {
- outstandingCommands.unshift(cmd);
- return;
- }
+ var cmd = outstandingCommands.shift();
+ if (!handleCommands(cmd)) {
+ outstandingCommands.unshift(cmd);
+ return;
+ }
}
}
}
BinCommands.prototype.get_16 = function() {
var v =
- this.u8[this.pos] +
- (this.u8[this.pos+1] << 8);
+ this.u8[this.pos] +
+ (this.u8[this.pos+1] << 8);
this.pos = this.pos + 2;
return v;
};
BinCommands.prototype.get_16s = function() {
var v = this.get_16 ();
if (v > 32767)
- return v - 65536;
+ return v - 65536;
else
- return v;
+ return v;
};
BinCommands.prototype.get_32 = function() {
var v =
- this.u8[this.pos] +
- (this.u8[this.pos+1] << 8) +
- (this.u8[this.pos+2] << 16) +
- (this.u8[this.pos+3] << 24);
+ this.u8[this.pos] +
+ (this.u8[this.pos+1] << 8) +
+ (this.u8[this.pos+2] << 16) +
+ (this.u8[this.pos+3] << 24);
this.pos = this.pos + 4;
return v;
};
var cmd = new BinCommands(message);
outstandingCommands.push(cmd);
if (outstandingCommands.length == 1) {
- handleOutstanding();
+ handleOutstanding();
}
}
function getSurfaceId(ev) {
var surface = ev.target.surface;
if (surface != undefined)
- return surface.id;
+ return surface.id;
return 0;
}
res.winX = absX;
res.winY = absY;
if (relativeId != 0) {
- var surface = surfaces[relativeId];
- res.winX = res.winX - surface.x;
- res.winY = res.winY - surface.y;
+ var surface = surfaces[relativeId];
+ res.winX = res.winX - surface.x;
+ res.winY = res.winY - surface.y;
}
return res;
function getEffectiveEventTarget (id) {
if (grab.window != null) {
- if (!grab.ownerEvents)
- return grab.window;
- if (id == 0)
- return grab.window;
+ if (!grab.ownerEvents)
+ return grab.window;
+ if (id == 0)
+ return grab.window;
}
return id;
}
function updateForEvent(ev) {
lastState &= ~(GDK_SHIFT_MASK|GDK_CONTROL_MASK|GDK_MOD1_MASK);
if (ev.shiftKey)
- lastState |= GDK_SHIFT_MASK;
+ lastState |= GDK_SHIFT_MASK;
if (ev.ctrlKey)
- lastState |= GDK_CONTROL_MASK;
+ lastState |= GDK_CONTROL_MASK;
if (ev.altKey)
- lastState |= GDK_MOD1_MASK;
+ lastState |= GDK_MOD1_MASK;
lastTimeStamp = ev.timeStamp;
}
var pos = getPositionsFromEvent(ev, id);
windowWithMouse = id;
if (windowWithMouse != 0) {
- sendInput ("e", [realWindowWithMouse, id, pos.rootX, pos.rootY, pos.winX, pos.winY, lastState, GDK_CROSSING_NORMAL]);
+ sendInput ("e", [realWindowWithMouse, id, pos.rootX, pos.rootY, pos.winX, pos.winY, lastState, GDK_CROSSING_NORMAL]);
}
}
var pos = getPositionsFromEvent(ev, id);
if (id != 0) {
- sendInput ("l", [realWindowWithMouse, id, pos.rootX, pos.rootY, pos.winX, pos.winY, lastState, GDK_CROSSING_NORMAL]);
+ sendInput ("l", [realWindowWithMouse, id, pos.rootX, pos.rootY, pos.winX, pos.winY, lastState, GDK_CROSSING_NORMAL]);
}
realWindowWithMouse = 0;
windowWithMouse = 0;
var pos;
if (windowWithMouse != id) {
- if (windowWithMouse != 0) {
- pos = getPositionsFromAbsCoord(lastX, lastY, windowWithMouse);
- sendInput ("l", [realWindowWithMouse, windowWithMouse, pos.rootX, pos.rootY, pos.winX, pos.winY, lastState, GDK_CROSSING_GRAB]);
- }
- pos = getPositionsFromAbsCoord(lastX, lastY, id);
- sendInput ("e", [realWindowWithMouse, id, pos.rootX, pos.rootY, pos.winX, pos.winY, lastState, GDK_CROSSING_GRAB]);
- windowWithMouse = id;
+ if (windowWithMouse != 0) {
+ pos = getPositionsFromAbsCoord(lastX, lastY, windowWithMouse);
+ sendInput ("l", [realWindowWithMouse, windowWithMouse, pos.rootX, pos.rootY, pos.winX, pos.winY, lastState, GDK_CROSSING_GRAB]);
+ }
+ pos = getPositionsFromAbsCoord(lastX, lastY, id);
+ sendInput ("e", [realWindowWithMouse, id, pos.rootX, pos.rootY, pos.winX, pos.winY, lastState, GDK_CROSSING_GRAB]);
+ windowWithMouse = id;
}
grab.window = id;
function doUngrab() {
var pos;
if (realWindowWithMouse != windowWithMouse) {
- if (windowWithMouse != 0) {
- pos = getPositionsFromAbsCoord(lastX, lastY, windowWithMouse);
- sendInput ("l", [realWindowWithMouse, windowWithMouse, pos.rootX, pos.rootY, pos.winX, pos.winY, lastState, GDK_CROSSING_UNGRAB]);
- }
- if (realWindowWithMouse != 0) {
- pos = getPositionsFromAbsCoord(lastX, lastY, realWindowWithMouse);
- sendInput ("e", [realWindowWithMouse, realWindowWithMouse, pos.rootX, pos.rootY, pos.winX, pos.winY, lastState, GDK_CROSSING_UNGRAB]);
- }
- windowWithMouse = realWindowWithMouse;
+ if (windowWithMouse != 0) {
+ pos = getPositionsFromAbsCoord(lastX, lastY, windowWithMouse);
+ sendInput ("l", [realWindowWithMouse, windowWithMouse, pos.rootX, pos.rootY, pos.winX, pos.winY, lastState, GDK_CROSSING_UNGRAB]);
+ }
+ if (realWindowWithMouse != 0) {
+ pos = getPositionsFromAbsCoord(lastX, lastY, realWindowWithMouse);
+ sendInput ("e", [realWindowWithMouse, realWindowWithMouse, pos.rootX, pos.rootY, pos.winX, pos.winY, lastState, GDK_CROSSING_UNGRAB]);
+ }
+ windowWithMouse = realWindowWithMouse;
}
grab.window = null;
}
var pos = getPositionsFromEvent(ev, id);
if (grab.window == null)
- doGrab (id, false, true);
+ doGrab (id, false, true);
sendInput ("b", [realWindowWithMouse, id, pos.rootX, pos.rootY, pos.winX, pos.winY, lastState, button]);
return false;
}
sendInput ("B", [realWindowWithMouse, id, pos.rootX, pos.rootY, pos.winX, pos.winY, lastState, button]);
if (grab.window != null && grab.implicit)
- doUngrab();
+ doUngrab();
return false;
}
function getEventKeySym(ev) {
if (typeof ev.which !== "undefined" && ev.which > 0)
- return ev.which;
+ return ev.which;
return ev.keyCode;
}
// translated keysym.
function getKeysymSpecial(ev) {
if (ev.keyCode in specialKeyTable) {
- var r = specialKeyTable[ev.keyCode];
- var flags = 0;
- if (typeof r != 'number') {
- flags = r[1];
- r = r[0];
- }
- if (ev.type === 'keydown' || flags & ON_KEYDOWN)
- return r;
+ var r = specialKeyTable[ev.keyCode];
+ var flags = 0;
+ if (typeof r != 'number') {
+ flags = r[1];
+ r = r[0];
+ }
+ if (ev.type === 'keydown' || flags & ON_KEYDOWN)
+ return r;
}
// If we don't hold alt or ctrl, then we should be safe to pass
// on to keypressed and look at the translated data
if (!ev.ctrlKey && !ev.altKey)
- return null;
+ return null;
var keysym = getEventKeySym(ev);
case 187 : keysym = 61; break; // = (IE)
case 188 : keysym = 44; break; // , (Mozilla, IE)
case 109 : // - (Mozilla, Opera)
- if (true /* TODO: check if browser is firefox or opera */)
- keysym = 45;
- break;
+ if (true /* TODO: check if browser is firefox or opera */)
+ keysym = 45;
+ break;
case 189 : keysym = 45; break; // - (IE)
case 190 : keysym = 46; break; // . (Mozilla, IE)
case 191 : keysym = 47; break; // / (Mozilla, IE)
/* Remap shifted and unshifted keys */
if (!!ev.shiftKey) {
- switch (keysym) {
- case 48 : keysym = 41 ; break; // ) (shifted 0)
- case 49 : keysym = 33 ; break; // ! (shifted 1)
- case 50 : keysym = 64 ; break; // @ (shifted 2)
- case 51 : keysym = 35 ; break; // # (shifted 3)
- case 52 : keysym = 36 ; break; // $ (shifted 4)
- case 53 : keysym = 37 ; break; // % (shifted 5)
- case 54 : keysym = 94 ; break; // ^ (shifted 6)
- case 55 : keysym = 38 ; break; // & (shifted 7)
- case 56 : keysym = 42 ; break; // * (shifted 8)
- case 57 : keysym = 40 ; break; // ( (shifted 9)
- case 59 : keysym = 58 ; break; // : (shifted `)
- case 61 : keysym = 43 ; break; // + (shifted ;)
- case 44 : keysym = 60 ; break; // < (shifted ,)
- case 45 : keysym = 95 ; break; // _ (shifted -)
- case 46 : keysym = 62 ; break; // > (shifted .)
- case 47 : keysym = 63 ; break; // ? (shifted /)
- case 96 : keysym = 126; break; // ~ (shifted `)
- case 91 : keysym = 123; break; // { (shifted [)
- case 92 : keysym = 124; break; // | (shifted \)
- case 93 : keysym = 125; break; // } (shifted ])
- case 39 : keysym = 34 ; break; // " (shifted ')
- }
+ switch (keysym) {
+ case 48 : keysym = 41 ; break; // ) (shifted 0)
+ case 49 : keysym = 33 ; break; // ! (shifted 1)
+ case 50 : keysym = 64 ; break; // @ (shifted 2)
+ case 51 : keysym = 35 ; break; // # (shifted 3)
+ case 52 : keysym = 36 ; break; // $ (shifted 4)
+ case 53 : keysym = 37 ; break; // % (shifted 5)
+ case 54 : keysym = 94 ; break; // ^ (shifted 6)
+ case 55 : keysym = 38 ; break; // & (shifted 7)
+ case 56 : keysym = 42 ; break; // * (shifted 8)
+ case 57 : keysym = 40 ; break; // ( (shifted 9)
+ case 59 : keysym = 58 ; break; // : (shifted `)
+ case 61 : keysym = 43 ; break; // + (shifted ;)
+ case 44 : keysym = 60 ; break; // < (shifted ,)
+ case 45 : keysym = 95 ; break; // _ (shifted -)
+ case 46 : keysym = 62 ; break; // > (shifted .)
+ case 47 : keysym = 63 ; break; // ? (shifted /)
+ case 96 : keysym = 126; break; // ~ (shifted `)
+ case 91 : keysym = 123; break; // { (shifted [)
+ case 92 : keysym = 124; break; // | (shifted \)
+ case 93 : keysym = 125; break; // } (shifted ])
+ case 39 : keysym = 34 ; break; // " (shifted ')
+ }
} else if ((keysym >= 65) && (keysym <=90)) {
- /* Remap unshifted A-Z */
- keysym += 32;
+ /* Remap unshifted A-Z */
+ keysym += 32;
} else if (ev.keyLocation === 3) {
- // numpad keys
- switch (keysym) {
- case 96 : keysym = 48; break; // 0
- case 97 : keysym = 49; break; // 1
- case 98 : keysym = 50; break; // 2
- case 99 : keysym = 51; break; // 3
- case 100: keysym = 52; break; // 4
- case 101: keysym = 53; break; // 5
- case 102: keysym = 54; break; // 6
- case 103: keysym = 55; break; // 7
- case 104: keysym = 56; break; // 8
- case 105: keysym = 57; break; // 9
- case 109: keysym = 45; break; // -
- case 110: keysym = 46; break; // .
- case 111: keysym = 47; break; // /
- }
+ // numpad keys
+ switch (keysym) {
+ case 96 : keysym = 48; break; // 0
+ case 97 : keysym = 49; break; // 1
+ case 98 : keysym = 50; break; // 2
+ case 99 : keysym = 51; break; // 3
+ case 100: keysym = 52; break; // 4
+ case 101: keysym = 53; break; // 5
+ case 102: keysym = 54; break; // 6
+ case 103: keysym = 55; break; // 7
+ case 104: keysym = 56; break; // 8
+ case 105: keysym = 57; break; // 9
+ case 109: keysym = 45; break; // -
+ case 110: keysym = 46; break; // .
+ case 111: keysym = 47; break; // /
+ }
}
return keysym;
keysym = getEventKeySym(ev);
if ((keysym > 255) && (keysym < 0xFF00)) {
- // Map Unicode outside Latin 1 to gdk keysyms
- keysym = unicodeTable[keysym];
- if (typeof keysym === 'undefined')
- keysym = 0;
+ // Map Unicode outside Latin 1 to gdk keysyms
+ keysym = unicodeTable[keysym];
+ if (typeof keysym === 'undefined')
+ keysym = 0;
}
return keysym;
function copyKeyEvent(ev) {
var members = ['type', 'keyCode', 'charCode', 'which',
- 'altKey', 'ctrlKey', 'shiftKey',
- 'keyLocation', 'keyIdentifier'], i, obj = {};
+ 'altKey', 'ctrlKey', 'shiftKey',
+ 'keyLocation', 'keyIdentifier'], i, obj = {};
for (i = 0; i < members.length; i++) {
- if (typeof ev[members[i]] !== "undefined")
- obj[members[i]] = ev[members[i]];
+ if (typeof ev[members[i]] !== "undefined")
+ obj[members[i]] = ev[members[i]];
}
return obj;
}
function getKeyEvent(keyCode, pop) {
var i, fev = null;
for (i = keyDownList.length-1; i >= 0; i--) {
- if (keyDownList[i].keyCode === keyCode) {
- if ((typeof pop !== "undefined") && pop)
- fev = keyDownList.splice(i, 1)[0];
- else
- fev = keyDownList[i];
- break;
- }
+ if (keyDownList[i].keyCode === keyCode) {
+ if ((typeof pop !== "undefined") && pop)
+ fev = keyDownList.splice(i, 1)[0];
+ else
+ fev = keyDownList[i];
+ break;
+ }
}
return fev;
}
function ignoreKeyEvent(ev) {
// Blarg. Some keys have a different keyCode on keyDown vs keyUp
if (ev.keyCode === 229) {
- // French AZERTY keyboard dead key.
- // Lame thing is that the respective keyUp is 219 so we can't
- // properly ignore the keyUp event
- return true;
+ // French AZERTY keyboard dead key.
+ // Lame thing is that the respective keyUp is 219 so we can't
+ // properly ignore the keyUp event
+ return true;
}
return false;
}
// Save keysym decoding for use in keyUp
fev.keysym = keysym;
if (keysym) {
- // If it is a key or key combination that might trigger
- // browser behaviors or it has no corresponding keyPress
- // event, then send it immediately
- if (!ignoreKeyEvent(ev))
- sendInput("k", [keysym, lastState]);
- suppress = true;
+ // If it is a key or key combination that might trigger
+ // browser behaviors or it has no corresponding keyPress
+ // event, then send it immediately
+ if (!ignoreKeyEvent(ev))
+ sendInput("k", [keysym, lastState]);
+ suppress = true;
}
if (! ignoreKeyEvent(ev)) {
- // Add it to the list of depressed keys
- pushKeyEvent(fev);
+ // Add it to the list of depressed keys
+ pushKeyEvent(fev);
}
if (suppress) {
- // Suppress bubbling/default actions
- return cancelEvent(ev);
+ // Suppress bubbling/default actions
+ return cancelEvent(ev);
}
// Allow the event to bubble and become a keyPress event which
var ev = (e ? e : window.event), kdlen = keyDownList.length, keysym = null;
if (((ev.which !== "undefined") && (ev.which === 0)) ||
- getKeysymSpecial(ev)) {
- // Firefox and Opera generate a keyPress event even if keyDown
- // is suppressed. But the keys we want to suppress will have
- // either:
- // - the which attribute set to 0
- // - getKeysymSpecial() will identify it
- return cancelEvent(ev);
+ getKeysymSpecial(ev)) {
+ // Firefox and Opera generate a keyPress event even if keyDown
+ // is suppressed. But the keys we want to suppress will have
+ // either:
+ // - the which attribute set to 0
+ // - getKeysymSpecial() will identify it
+ return cancelEvent(ev);
}
keysym = getKeysym(ev);
// that the keyUp event will be able to have the character code
// translation available.
if (kdlen > 0) {
- keyDownList[kdlen-1].keysym = keysym;
+ keyDownList[kdlen-1].keysym = keysym;
} else {
- //log("keyDownList empty when keyPress triggered");
+ //log("keyDownList empty when keyPress triggered");
}
// Send the translated keysym
if (keysym > 0)
- sendInput ("k", [keysym, lastState]);
+ sendInput ("k", [keysym, lastState]);
// Stop keypress events just in case
return cancelEvent(ev);
fev = getKeyEvent(ev.keyCode, true);
if (fev)
- keysym = fev.keysym;
+ keysym = fev.keysym;
else {
- //log("Key event (keyCode = " + ev.keyCode + ") not found on keyDownList");
- keysym = 0;
+ //log("Key event (keyCode = " + ev.keyCode + ") not found on keyDownList");
+ keysym = 0;
}
if (keysym > 0)
- sendInput ("K", [keysym, lastState]);
+ sendInput ("K", [keysym, lastState]);
return cancelEvent(ev);
}
{
ev = ev ? ev : window.event;
if (ev.stopPropagation)
- ev.stopPropagation();
+ ev.stopPropagation();
if (ev.preventDefault)
- ev.preventDefault();
+ ev.preventDefault();
ev.cancelBubble = true;
ev.cancel = true;
ev.returnValue = false;
var offset = ev.detail ? ev.detail : -ev.wheelDelta;
var dir = 0;
if (offset > 0)
- dir = 1;
+ dir = 1;
sendInput ("s", [realWindowWithMouse, id, pos.rootX, pos.rootY, pos.winX, pos.winY, lastState, dir]);
return cancelEvent(ev);
w = window.innerWidth;
h = window.innerHeight;
window.onresize = function(ev) {
- var w, h;
- w = window.innerWidth;
- h = window.innerHeight;
- sendInput ("d", [w, h]);
+ var w, h;
+ w = window.innerWidth;
+ h = window.innerHeight;
+ sendInput ("d", [w, h]);
};
sendInput ("d", [w, h]);
}
var url = window.location.toString();
var query_string = url.split("?");
if (query_string.length > 1) {
- var params = query_string[1].split("&");
+ var params = query_string[1].split("&");
for (var i=0; i<params.length; i++) {
var pair = params[i].split("=");
ws.binaryType = "arraybuffer";
ws.onopen = function() {
- inputSocket = ws;
+ inputSocket = ws;
};
ws.onclose = function() {
- if (inputSocket != null)
- alert ("disconnected");
- inputSocket = null;
+ if (inputSocket != null)
+ alert ("disconnected");
+ inputSocket = null;
};
ws.onmessage = function(event) {
- handleMessage(event.data);
+ handleMessage(event.data);
};
var iOS = /(iPad|iPhone|iPod)/g.test( navigator.userAgent );
}
G_DEFINE_TYPE (GdkWindowImplBroadway,
- gdk_window_impl_broadway,
- GDK_TYPE_WINDOW_IMPL)
+ gdk_window_impl_broadway,
+ GDK_TYPE_WINDOW_IMPL)
static GdkDisplay *
find_broadway_display (void)
GdkWindowImplBroadway *impl = l->data;
if (impl->dirty)
- {
- GdkTexture *texture;
- guint32 texture_id;
+ {
+ GdkTexture *texture;
+ guint32 texture_id;
+
+ impl->dirty = FALSE;
+ updated_surface = TRUE;
- impl->dirty = FALSE;
- updated_surface = TRUE;
+ if (impl->texture_id)
+ gdk_broadway_server_release_texture (display->server, impl->texture_id);
+ impl->texture_id = 0;
- if (impl->texture_id)
- gdk_broadway_server_release_texture (display->server, impl->texture_id);
- impl->texture_id = 0;
+ texture = gdk_texture_new_for_surface (impl->surface);
+ texture_id = gdk_broadway_server_upload_texture (display->server, texture);
+ g_object_unref (texture);
- texture = gdk_texture_new_for_surface (impl->surface);
- texture_id = gdk_broadway_server_upload_texture (display->server, texture);
- g_object_unref (texture);
+ impl->texture_id = texture_id;
- impl->texture_id = texture_id;
- _gdk_broadway_server_window_update (display->server,
- impl->id,
- texture_id);
+ if (impl->node_data)
+ gdk_broadway_server_window_set_nodes (display->server, impl->id, impl->node_data);
- }
+ _gdk_broadway_server_window_update (display->server,
+ impl->id,
+ texture_id);
+
+ }
}
/* We sync here to ensure all references to the impl->surface memory
void
_gdk_broadway_display_create_window_impl (GdkDisplay *display,
- GdkWindow *window,
- GdkWindow *real_parent,
- GdkEventMask event_mask,
- GdkWindowAttr *attributes)
+ GdkWindow *window,
+ GdkWindow *real_parent,
+ GdkEventMask event_mask,
+ GdkWindowAttr *attributes)
{
GdkWindowImplBroadway *impl;
GdkBroadwayDisplay *broadway_display;
impl = g_object_new (GDK_TYPE_WINDOW_IMPL_BROADWAY, NULL);
window->impl = (GdkWindowImpl *)impl;
impl->id = _gdk_broadway_server_new_window (broadway_display->server,
- window->x,
- window->y,
- window->width,
- window->height,
- window->window_type == GDK_WINDOW_TEMP);
+ window->x,
+ window->y,
+ window->width,
+ window->height,
+ window->window_type == GDK_WINDOW_TEMP);
g_hash_table_insert (broadway_display->id_ht, GINT_TO_POINTER(impl->id), window);
impl->wrapper = window;
g_assert (window->window_type == GDK_WINDOW_TOPLEVEL ||
- window->window_type == GDK_WINDOW_TEMP);
+ window->window_type == GDK_WINDOW_TEMP);
g_assert (window->parent == NULL);
broadway_display->toplevels = g_list_prepend (broadway_display->toplevels, impl);
cairo_surface_destroy (impl->surface);
impl->surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
- gdk_window_get_width (impl->wrapper),
- gdk_window_get_height (impl->wrapper));
+ gdk_window_get_width (impl->wrapper),
+ gdk_window_get_height (impl->wrapper));
}
if (impl->ref_surface)
{
cairo_surface_set_user_data (impl->ref_surface, &gdk_broadway_cairo_key,
- NULL, NULL);
+ NULL, NULL);
impl->ref_surface = NULL;
}
if (!impl->ref_surface)
{
impl->ref_surface =
- cairo_surface_create_for_rectangle (impl->surface,
- 0, 0,
- w, h);
+ cairo_surface_create_for_rectangle (impl->surface,
+ 0, 0,
+ w, h);
if (impl->ref_surface)
- cairo_surface_set_user_data (impl->ref_surface, &gdk_broadway_cairo_key,
- impl, ref_surface_destroyed);
+ cairo_surface_set_user_data (impl->ref_surface, &gdk_broadway_cairo_key,
+ impl, ref_surface_destroyed);
}
else
cairo_surface_reference (impl->ref_surface);
static void
_gdk_broadway_window_destroy (GdkWindow *window,
- gboolean recursing,
- gboolean foreign_destroy)
+ gboolean recursing,
+ gboolean foreign_destroy)
{
GdkWindowImplBroadway *impl;
GdkBroadwayDisplay *broadway_display;
impl = GDK_WINDOW_IMPL_BROADWAY (window->impl);
+ if (impl->node_data)
+ g_array_unref (impl->node_data);
+ if (impl->node_data_textures)
+ g_ptr_array_unref (impl->node_data_textures);
+
_gdk_broadway_selection_window_destroyed (window);
_gdk_broadway_window_grab_check_destroy (window);
{
cairo_surface_finish (impl->ref_surface);
cairo_surface_set_user_data (impl->ref_surface, &gdk_broadway_cairo_key,
- NULL, NULL);
+ NULL, NULL);
}
if (impl->surface)
}
+void
+gdk_broadway_window_set_nodes (GdkWindow *window,
+ GArray *nodes,
+ GPtrArray *node_textures)
+{
+ GdkWindowImplBroadway *impl;
+ GdkBroadwayDisplay *broadway_display;
+
+ g_return_if_fail (GDK_IS_WINDOW (window));
+
+ impl = GDK_WINDOW_IMPL_BROADWAY (window->impl);
+
+ broadway_display = GDK_BROADWAY_DISPLAY (gdk_window_get_display (window));
+
+ if (nodes)
+ g_array_ref (nodes);
+ if (impl->node_data)
+ g_array_unref (impl->node_data);
+ impl->node_data = nodes;
+
+ if (node_textures)
+ g_ptr_array_ref (node_textures);
+ if (impl->node_data_textures)
+ g_ptr_array_unref (impl->node_data_textures);
+ impl->node_data_textures = node_textures;
+
+ gdk_broadway_server_window_set_nodes (broadway_display->server, impl->id, impl->node_data);
+}
+
/* This function is called when the XWindow is really gone.
*/
static void
broadway_display = GDK_BROADWAY_DISPLAY (gdk_window_get_display (window));
_gdk_broadway_window_grab_check_unmap (window,
- _gdk_broadway_server_get_next_serial (broadway_display->server));
+ _gdk_broadway_server_get_next_serial (broadway_display->server));
if (_gdk_broadway_server_window_hide (broadway_display->server, impl->id))
queue_flush (window);
static void
gdk_window_broadway_move_resize (GdkWindow *window,
- gboolean with_move,
- gint x,
- gint y,
- gint width,
- gint height)
+ gboolean with_move,
+ gint x,
+ gint y,
+ gint width,
+ gint height)
{
GdkWindowImplBroadway *impl = GDK_WINDOW_IMPL_BROADWAY (window->impl);
GdkBroadwayDisplay *broadway_display;
if (width > 0 || height > 0)
{
if (width < 1)
- width = 1;
+ width = 1;
if (height < 1)
- height = 1;
+ height = 1;
if (width != window->width ||
- height != window->height)
- {
- size_changed = TRUE;
-
- /* Resize clears the content */
- impl->dirty = TRUE;
- impl->last_synced = FALSE;
-
- window->width = width;
- window->height = height;
- _gdk_broadway_window_resize_surface (window);
- }
+ height != window->height)
+ {
+ size_changed = TRUE;
+
+ /* Resize clears the content */
+ impl->dirty = TRUE;
+ impl->last_synced = FALSE;
+
+ window->width = width;
+ window->height = height;
+ _gdk_broadway_window_resize_surface (window);
+ }
}
_gdk_broadway_server_window_move_resize (broadway_display->server,
- impl->id,
- with_move,
- x, y,
- window->width, window->height);
+ impl->id,
+ with_move,
+ x, y,
+ window->width, window->height);
queue_flush (window);
if (size_changed)
window->resize_count++;
static void
gdk_window_broadway_restack_toplevel (GdkWindow *window,
- GdkWindow *sibling,
- gboolean above)
+ GdkWindow *sibling,
+ gboolean above)
{
}
static void
gdk_broadway_window_focus (GdkWindow *window,
- guint32 timestamp)
+ guint32 timestamp)
{
GdkWindowImplBroadway *impl;
GdkBroadwayDisplay *broadway_display;
impl = GDK_WINDOW_IMPL_BROADWAY (window->impl);
broadway_display = GDK_BROADWAY_DISPLAY (gdk_window_get_display (window));
_gdk_broadway_server_window_focus (broadway_display->server,
- impl->id);
+ impl->id);
}
static void
gdk_broadway_window_set_type_hint (GdkWindow *window,
- GdkWindowTypeHint hint)
+ GdkWindowTypeHint hint)
{
}
static void
gdk_broadway_window_set_modal_hint (GdkWindow *window,
- gboolean modal)
+ gboolean modal)
{
}
static void
gdk_broadway_window_set_skip_taskbar_hint (GdkWindow *window,
- gboolean skips_taskbar)
+ gboolean skips_taskbar)
{
}
static void
gdk_broadway_window_set_skip_pager_hint (GdkWindow *window,
- gboolean skips_pager)
+ gboolean skips_pager)
{
}
static void
gdk_broadway_window_set_urgency_hint (GdkWindow *window,
- gboolean urgent)
+ gboolean urgent)
{
}
static void
gdk_broadway_window_set_geometry_hints (GdkWindow *window,
- const GdkGeometry *geometry,
- GdkWindowHints geom_mask)
+ const GdkGeometry *geometry,
+ GdkWindowHints geom_mask)
{
GdkWindowImplBroadway *impl;
static void
gdk_broadway_window_set_title (GdkWindow *window,
- const gchar *title)
+ const gchar *title)
{
}
static void
gdk_broadway_window_set_role (GdkWindow *window,
- const gchar *role)
+ const gchar *role)
{
}
static void
gdk_broadway_window_set_startup_id (GdkWindow *window,
- const gchar *startup_id)
+ const gchar *startup_id)
{
}
static void
gdk_broadway_window_set_transient_for (GdkWindow *window,
- GdkWindow *parent)
+ GdkWindow *parent)
{
GdkBroadwayDisplay *display;
GdkWindowImplBroadway *impl;
static void
gdk_window_broadway_get_geometry (GdkWindow *window,
- gint *x,
- gint *y,
- gint *width,
- gint *height)
+ gint *x,
+ gint *y,
+ gint *width,
+ gint *height)
{
GdkWindowImplBroadway *impl;
static void
gdk_window_broadway_get_root_coords (GdkWindow *window,
- gint x,
- gint y,
- gint *root_x,
- gint *root_y)
+ gint x,
+ gint y,
+ gint *root_x,
+ gint *root_y)
{
GdkWindowImplBroadway *impl;
static void
gdk_broadway_window_get_frame_extents (GdkWindow *window,
- GdkRectangle *rect)
+ GdkRectangle *rect)
{
g_return_if_fail (rect != NULL);
static gboolean
gdk_window_broadway_get_device_state (GdkWindow *window,
- GdkDevice *device,
- gdouble *x,
- gdouble *y,
- GdkModifierType *mask)
+ GdkDevice *device,
+ gdouble *x,
+ gdouble *y,
+ GdkModifierType *mask)
{
GdkWindow *child;
static void
gdk_window_broadway_set_events (GdkWindow *window,
- GdkEventMask event_mask)
+ GdkEventMask event_mask)
{
if (!GDK_WINDOW_DESTROYED (window))
{
static void
gdk_window_broadway_shape_combine_region (GdkWindow *window,
- const cairo_region_t *shape_region,
- gint offset_x,
- gint offset_y)
+ const cairo_region_t *shape_region,
+ gint offset_x,
+ gint offset_y)
{
}
static void
gdk_window_broadway_input_shape_combine_region (GdkWindow *window,
- const cairo_region_t *shape_region,
- gint offset_x,
- gint offset_y)
+ const cairo_region_t *shape_region,
+ gint offset_x,
+ gint offset_y)
{
}
static void
gdk_broadway_window_set_accept_focus (GdkWindow *window,
- gboolean accept_focus)
+ gboolean accept_focus)
{
accept_focus = accept_focus != FALSE;
static void
gdk_broadway_window_set_focus_on_map (GdkWindow *window,
- gboolean focus_on_map)
+ gboolean focus_on_map)
{
focus_on_map = focus_on_map != FALSE;
static void
gdk_broadway_window_set_icon_list (GdkWindow *window,
- GList *surfaces)
+ GList *surfaces)
{
}
static void
gdk_broadway_window_set_icon_name (GdkWindow *window,
- const gchar *name)
+ const gchar *name)
{
if (GDK_WINDOW_DESTROYED (window) ||
!WINDOW_IS_TOPLEVEL (window))
return;
g_object_set_qdata (G_OBJECT (window), g_quark_from_static_string ("gdk-icon-name-set"),
- GUINT_TO_POINTER (name != NULL));
+ GUINT_TO_POINTER (name != NULL));
}
static void
gdk_synthesize_window_state (window, GDK_WINDOW_STATE_MAXIMIZED, 0);
gdk_window_move_resize (window,
- impl->pre_maximize_x,
- impl->pre_maximize_y,
- impl->pre_maximize_width,
- impl->pre_maximize_height);
+ impl->pre_maximize_x,
+ impl->pre_maximize_y,
+ impl->pre_maximize_width,
+ impl->pre_maximize_height);
}
static void
static void
gdk_broadway_window_set_keep_above (GdkWindow *window,
- gboolean setting)
+ gboolean setting)
{
g_return_if_fail (GDK_IS_WINDOW (window));
static void
gdk_broadway_window_set_group (GdkWindow *window,
- GdkWindow *leader)
+ GdkWindow *leader)
{
}
static void
gdk_broadway_window_set_decorations (GdkWindow *window,
- GdkWMDecoration decorations)
+ GdkWMDecoration decorations)
{
if (GDK_WINDOW_DESTROYED (window) ||
!WINDOW_IS_TOPLEVEL (window))
static gboolean
gdk_broadway_window_get_decorations (GdkWindow *window,
- GdkWMDecoration *decorations)
+ GdkWMDecoration *decorations)
{
gboolean result = FALSE;
static void
gdk_broadway_window_set_functions (GdkWindow *window,
- GdkWMFunction functions)
+ GdkWMFunction functions)
{
g_return_if_fail (GDK_IS_WINDOW (window));
static MoveResizeData *
get_move_resize_data (GdkDisplay *display,
- gboolean create)
+ gboolean create)
{
GdkBroadwayDisplay *broadway_display;
MoveResizeData *mv_resize;
static void
update_pos (MoveResizeData *mv_resize,
- gint new_root_x,
- gint new_root_y)
+ gint new_root_x,
+ gint new_root_y)
{
gint dx, dy;
h = mv_resize->moveresize_orig_height;
switch (mv_resize->resize_edge)
- {
- case GDK_WINDOW_EDGE_NORTH_WEST:
- x += dx;
- y += dy;
- w -= dx;
- h -= dy;
- break;
- case GDK_WINDOW_EDGE_NORTH:
- y += dy;
- h -= dy;
- break;
- case GDK_WINDOW_EDGE_NORTH_EAST:
- y += dy;
- h -= dy;
- w += dx;
- break;
- case GDK_WINDOW_EDGE_SOUTH_WEST:
- h += dy;
- x += dx;
- w -= dx;
- break;
- case GDK_WINDOW_EDGE_SOUTH_EAST:
- w += dx;
- h += dy;
- break;
- case GDK_WINDOW_EDGE_SOUTH:
- h += dy;
- break;
- case GDK_WINDOW_EDGE_EAST:
- w += dx;
- break;
- case GDK_WINDOW_EDGE_WEST:
- x += dx;
- w -= dx;
- break;
+ {
+ case GDK_WINDOW_EDGE_NORTH_WEST:
+ x += dx;
+ y += dy;
+ w -= dx;
+ h -= dy;
+ break;
+ case GDK_WINDOW_EDGE_NORTH:
+ y += dy;
+ h -= dy;
+ break;
+ case GDK_WINDOW_EDGE_NORTH_EAST:
+ y += dy;
+ h -= dy;
+ w += dx;
+ break;
+ case GDK_WINDOW_EDGE_SOUTH_WEST:
+ h += dy;
+ x += dx;
+ w -= dx;
+ break;
+ case GDK_WINDOW_EDGE_SOUTH_EAST:
+ w += dx;
+ h += dy;
+ break;
+ case GDK_WINDOW_EDGE_SOUTH:
+ h += dy;
+ break;
+ case GDK_WINDOW_EDGE_EAST:
+ w += dx;
+ break;
+ case GDK_WINDOW_EDGE_WEST:
+ x += dx;
+ w -= dx;
+ break;
default:
break;
- }
+ }
x = MAX (x, 0);
y = MAX (y, 0);
h = MAX (h, 1);
if (mv_resize->moveresize_geom_mask)
- {
- gdk_window_constrain_size (&mv_resize->moveresize_geometry,
- mv_resize->moveresize_geom_mask,
- w, h, &w, &h);
- }
+ {
+ gdk_window_constrain_size (&mv_resize->moveresize_geometry,
+ mv_resize->moveresize_geom_mask,
+ w, h, &w, &h);
+ }
gdk_window_move_resize (mv_resize->moveresize_window, x, y, w, h);
}
static gboolean
moveresize_lookahead (GdkDisplay *display,
- MoveResizeData *mv_resize,
- BroadwayInputMsg *event)
+ MoveResizeData *mv_resize,
+ BroadwayInputMsg *event)
{
GdkBroadwayDisplay *broadway_display;
gboolean
_gdk_broadway_moveresize_handle_event (GdkDisplay *display,
- BroadwayInputMsg *event)
+ BroadwayInputMsg *event)
{
guint button_mask = 0;
MoveResizeData *mv_resize = get_move_resize_data (display, FALSE);
case BROADWAY_EVENT_POINTER_MOVE:
if (mv_resize->moveresize_window->resize_count > 0)
- {
- if (mv_resize->moveresize_pending_event)
- *mv_resize->moveresize_pending_event = *event;
- else
- mv_resize->moveresize_pending_event =
- g_memdup (event, sizeof (BroadwayInputMsg));
-
- break;
- }
+ {
+ if (mv_resize->moveresize_pending_event)
+ *mv_resize->moveresize_pending_event = *event;
+ else
+ mv_resize->moveresize_pending_event =
+ g_memdup (event, sizeof (BroadwayInputMsg));
+
+ break;
+ }
if (!moveresize_lookahead (display, mv_resize, event))
- break;
+ break;
update_pos (mv_resize,
- event->pointer.root_x,
- event->pointer.root_y);
+ event->pointer.root_x,
+ event->pointer.root_y);
/* This should never be triggered in normal cases, but in the
* case where the drag started without an implicit grab being
* get a permanently stuck grab.
*/
if ((event->pointer.state & button_mask) == 0)
- finish_drag (mv_resize);
+ finish_drag (mv_resize);
break;
case BROADWAY_EVENT_BUTTON_RELEASE:
update_pos (mv_resize,
- event->pointer.root_x,
- event->pointer.root_y);
+ event->pointer.root_x,
+ event->pointer.root_y);
if (event->button.button == mv_resize->moveresize_button)
- finish_drag (mv_resize);
+ finish_drag (mv_resize);
break;
default:
break;
gboolean
_gdk_broadway_moveresize_configure_done (GdkDisplay *display,
- GdkWindow *window)
+ GdkWindow *window)
{
BroadwayInputMsg *tmp_event;
MoveResizeData *mv_resize = get_move_resize_data (display, FALSE);
static void
create_moveresize_window (MoveResizeData *mv_resize,
- guint32 timestamp)
+ guint32 timestamp)
{
GdkGrabStatus status;
GdkSeat *seat;
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
status = gdk_device_grab (pointer,
- mv_resize->moveresize_emulation_window,
- GDK_OWNERSHIP_APPLICATION,
- FALSE,
- GDK_BUTTON_RELEASE_MASK |
- GDK_POINTER_MOTION_MASK,
- NULL,
- timestamp);
+ mv_resize->moveresize_emulation_window,
+ GDK_OWNERSHIP_APPLICATION,
+ FALSE,
+ GDK_BUTTON_RELEASE_MASK |
+ GDK_POINTER_MOTION_MASK,
+ NULL,
+ timestamp);
G_GNUC_END_IGNORE_DEPRECATIONS;
if (status != GDK_GRAB_SUCCESS)
mv_resize->moveresize_geometry.win_gravity == GDK_GRAVITY_STATIC)
{
gdk_window_get_origin (mv_resize->moveresize_window,
- &mv_resize->moveresize_orig_x,
- &mv_resize->moveresize_orig_y);
+ &mv_resize->moveresize_orig_x,
+ &mv_resize->moveresize_orig_y);
}
else
{
gdk_window_get_frame_extents (mv_resize->moveresize_window, &rect);
gdk_window_get_geometry (mv_resize->moveresize_window,
- NULL, NULL, &width, &height);
+ NULL, NULL, &width, &height);
switch (mv_resize->moveresize_geometry.win_gravity)
- {
- case GDK_GRAVITY_NORTH_WEST:
- mv_resize->moveresize_orig_x = rect.x;
- mv_resize->moveresize_orig_y = rect.y;
- break;
- case GDK_GRAVITY_NORTH:
- mv_resize->moveresize_orig_x = rect.x + rect.width / 2 - width / 2;
- mv_resize->moveresize_orig_y = rect.y;
- break;
- case GDK_GRAVITY_NORTH_EAST:
- mv_resize->moveresize_orig_x = rect.x + rect.width - width;
- mv_resize->moveresize_orig_y = rect.y;
- break;
- case GDK_GRAVITY_WEST:
- mv_resize->moveresize_orig_x = rect.x;
- mv_resize->moveresize_orig_y = rect.y + rect.height / 2 - height / 2;
- break;
- case GDK_GRAVITY_CENTER:
- mv_resize->moveresize_orig_x = rect.x + rect.width / 2 - width / 2;
- mv_resize->moveresize_orig_y = rect.y + rect.height / 2 - height / 2;
- break;
- case GDK_GRAVITY_EAST:
- mv_resize->moveresize_orig_x = rect.x + rect.width - width;
- mv_resize->moveresize_orig_y = rect.y + rect.height / 2 - height / 2;
- break;
- case GDK_GRAVITY_SOUTH_WEST:
- mv_resize->moveresize_orig_x = rect.x;
- mv_resize->moveresize_orig_y = rect.y + rect.height - height;
- break;
- case GDK_GRAVITY_SOUTH:
- mv_resize->moveresize_orig_x = rect.x + rect.width / 2 - width / 2;
- mv_resize->moveresize_orig_y = rect.y + rect.height - height;
- break;
- case GDK_GRAVITY_SOUTH_EAST:
- mv_resize->moveresize_orig_x = rect.x + rect.width - width;
- mv_resize->moveresize_orig_y = rect.y + rect.height - height;
- break;
+ {
+ case GDK_GRAVITY_NORTH_WEST:
+ mv_resize->moveresize_orig_x = rect.x;
+ mv_resize->moveresize_orig_y = rect.y;
+ break;
+ case GDK_GRAVITY_NORTH:
+ mv_resize->moveresize_orig_x = rect.x + rect.width / 2 - width / 2;
+ mv_resize->moveresize_orig_y = rect.y;
+ break;
+ case GDK_GRAVITY_NORTH_EAST:
+ mv_resize->moveresize_orig_x = rect.x + rect.width - width;
+ mv_resize->moveresize_orig_y = rect.y;
+ break;
+ case GDK_GRAVITY_WEST:
+ mv_resize->moveresize_orig_x = rect.x;
+ mv_resize->moveresize_orig_y = rect.y + rect.height / 2 - height / 2;
+ break;
+ case GDK_GRAVITY_CENTER:
+ mv_resize->moveresize_orig_x = rect.x + rect.width / 2 - width / 2;
+ mv_resize->moveresize_orig_y = rect.y + rect.height / 2 - height / 2;
+ break;
+ case GDK_GRAVITY_EAST:
+ mv_resize->moveresize_orig_x = rect.x + rect.width - width;
+ mv_resize->moveresize_orig_y = rect.y + rect.height / 2 - height / 2;
+ break;
+ case GDK_GRAVITY_SOUTH_WEST:
+ mv_resize->moveresize_orig_x = rect.x;
+ mv_resize->moveresize_orig_y = rect.y + rect.height - height;
+ break;
+ case GDK_GRAVITY_SOUTH:
+ mv_resize->moveresize_orig_x = rect.x + rect.width / 2 - width / 2;
+ mv_resize->moveresize_orig_y = rect.y + rect.height - height;
+ break;
+ case GDK_GRAVITY_SOUTH_EAST:
+ mv_resize->moveresize_orig_x = rect.x + rect.width - width;
+ mv_resize->moveresize_orig_y = rect.y + rect.height - height;
+ break;
case GDK_GRAVITY_STATIC:
- default:
- mv_resize->moveresize_orig_x = rect.x;
- mv_resize->moveresize_orig_y = rect.y;
- break;
- }
+ default:
+ mv_resize->moveresize_orig_x = rect.x;
+ mv_resize->moveresize_orig_y = rect.y;
+ break;
+ }
}
}
static void
gdk_broadway_window_begin_resize_drag (GdkWindow *window,
- GdkWindowEdge edge,
+ GdkWindowEdge edge,
GdkDevice *device,
- gint button,
- gint root_x,
- gint root_y,
- guint32 timestamp)
+ gint button,
+ gint root_x,
+ gint root_y,
+ guint32 timestamp)
{
MoveResizeData *mv_resize;
GdkWindowImplBroadway *impl;
static void
gdk_broadway_window_begin_move_drag (GdkWindow *window,
GdkDevice *device,
- gint button,
- gint root_x,
- gint root_y,
- guint32 timestamp)
+ gint button,
+ gint root_x,
+ gint root_y,
+ guint32 timestamp)
{
MoveResizeData *mv_resize;
GdkWindowImplBroadway *impl;
static void
gdk_broadway_window_set_opacity (GdkWindow *window,
- gdouble opacity)
+ gdouble opacity)
{
g_return_if_fail (GDK_IS_WINDOW (window));